package org.zz.file;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class FileUtil {
	public static ArrayList<String> ReadTXTFile(final String path,String encoding){
		File txtFile = new File(path);
		if(!txtFile.exists() && !txtFile.isFile())
			return null;
		BufferedReader reader = null;
		try {
			reader = new BufferedReader(new InputStreamReader (new FileInputStream(txtFile),encoding));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
		ArrayList<String> lineList = new ArrayList<String>();
		try {
			for(String strLine = reader.readLine();strLine != null; strLine = reader.readLine()){
				lineList.add(strLine);
			}
			reader.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return lineList;
	}
	public static void main(String[] args) {
		System.out.println(ReadTXTFile("./res/EnglishStopWords.txt","UTF-8"));
	}
}
